# ============================================================================
#	TuP[u卪؂v
# ============================================================================
include	/pic/pic.mak
# =============================================================================
#	Ώۃt@C
# =============================================================================
DB	=	${BTD}\daittl.btd
DC	=	${CHR}\daittl.chr

DAITTL	=	${DB} ${DC}

CHRS	=	dai.chr dais.chr
PALS	=	daittl.pal dai.pal dais.pal
SPTS	=	dais.spt
# =============================================================================
#	^[Qbg
# =============================================================================
all:	${DAITTL} ${PALS} ${CHRS} ${BB} ${B2} ${SPTS}\
	${BTD}\slot.bgd ${BTD}\daikon.bgd\
	${BTD}\dai.btd 	${BTD}\dai2.btd

clean:
	-rm ${DAITTL}
	-rm ${BB} ${B2} ${SB}
	${cmdsplit -rm %,60,${addprefix ${PAL}\,${PALS}}}
	${cmdsplit -rm %,60,${addprefix ${CHR}\,${CHRS}}}
	${cmdsplit -rm %,60,${addprefix ${SPT}\,${SPTS}}}
# =============================================================================
#	IȐK
# =============================================================================
${DB} ${DC}:	daittl.cbb daittl.cgb
	copy daittl.cbb $0.cbb
	copy daittl.cgb $0.cgb
	bgcmp3 $0.cbb $0.cgb
	nulcut -b $0.cbb $1
	prs $1 ${DC}
	cbat -d -X0 -Y0 -x32 -y32 -o$1 $0.cgb
	lzss -e $1 ${DB}
	outbin -h -b32,32 ${DB}

daittl.pal:	daittl.ccb
	pakccb -s -u1 $^ ${PAL}\${@F}

# ----------------------------------------------------------------------------
${BTD}\dai.btd:	dai.cgb
	cbat -d -X0 -Y0 -x32 -y32 -o$1 $^
	lzss -e $1 $@
	outbin -h -b32,32 $@

${BTD}\dai2.btd:	dai.cgb
	cbat -d -X32 -Y0 -x2 -y4 -o$1 $^
	lzss -e $1 $@
	outbin -h -b2,4 $@

${BTD}\slot.bgd:		dai.cgb
	del $@
	cgbcut -t0,32 -l4,4 $^ $0
	bin2dw $0 >>$@
	cgbcut -t4,32 -l4,4 $^ $0
	bin2dw $0 >>$@
	cgbcut -t8,32 -l4,4 $^ $0
	bin2dw $0 >>$@
	cgbcut -t12,32 -l4,4 $^ $0
	bin2dw $0 >>$@
	cgbcut -t16,32 -l4,4 $^ $0
	bin2dw $0 >>$@
	cgbcut -t20,32 -l4,4 $^ $0
	bin2dw $0 >>$@
	cgbcut -t24,32 -l4,4 $^ $0
	bin2dw $0 >>$@

 ${BTD}\daikon.bgd:		dai.cgb
	del $@
	cgbcut -t0,36 -l2,2 $^ $0
	bin2dw $0 >>$@
	cgbcut -t2,36 -l1,1 $^ $0
	bin2dw $0 >>$@
	cgbcut -t2,37 -l1,1 $^ $0
	bin2dw $0 >>$@

dai.pal:	dai.ccb
	nulcut -c $^ $0
	pakccb -s $0 ${PAL}\${@F}

dai.chr:	dai.cbb
	nulcut -b $^ $1
	prs $1 ${CHR}\${@F}
# ----------------------------------------------------------------------------
dai:	dai0.csb dai1.csb dai2.csb dai3.csb dai0.ccb\
	man.cab daikon.cab daikon2.cab 10t.cab king.cab lee.cab \
	roba.cab missile.cab pachinko.cab omeme.cab yuge.cab
	echo dai0.csb/0>$@
	echo dai1.csb/1>>$@
	echo dai2.csb/2>>$@
	echo dai3.csb/3>>$@
	echo dai0.ccb>>$@
	echo man.cab>>$@
	echo daikon.cab>>$@
	echo daikon2.cab>>$@
	echo 10t.cab>>$@
	echo king.cab>>$@
	echo lee.cab>>$@
	echo roba.cab>>$@
	echo missile.cab>>$@
	echo pachinko.cab>>$@
	echo omeme.cab>>$@
	echo yuge.cab>>$@

tmp\dai.chr tmp\dai.pal tmp\dai.cab:	dai
	spcmp -j -otmp\dai @$^
	spcmp -otmp\dai @$^

dais.chr:	tmp\dai.chr
	prs $^ ${CHR}\${@F}
dais.pal:	tmp\dai.pal
	pakccb -s $^ ${PAL}\${@F}
dais.spt:	tmp\dai.cab
	echo  include ${GSYS}\objtbl.h>$0.s
	cabtbl -t -f1 $^ >>$0.s
	as -o$0.o $0.s
	lk -b${SPT}\${@F} /cseg:0,0 $0.o

